package cc.magicjson.scenario.implement.module.jdbc.template.monitor;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import static org.apache.logging.log4j.Level.*;

public class TransactionLogger {
        private static final Logger TRANSACTION_LOGGER = LogManager.getLogger("TransactionLogger");

        public static void log(Level level, String message) {
            if (level.equals(ERROR)) {
                TRANSACTION_LOGGER.error(message);
            } else if (level.equals(WARN)) {
                TRANSACTION_LOGGER.warn(message);
            } else if (level.equals(INFO)) {
                TRANSACTION_LOGGER.info(message);
            } else if (level.equals(DEBUG)) {
                TRANSACTION_LOGGER.debug(message);
            } else if (level.equals(TRACE)) {
                TRANSACTION_LOGGER.trace(message);
            } else {
                TRANSACTION_LOGGER.info(message);
            }
        }

        public static void error(String message, Throwable t) {
            TRANSACTION_LOGGER.error(message, t);
        }

        public static Logger getLogger() {
            return TRANSACTION_LOGGER;
        }
}
